{% extends "master.html" %}
{% block subtitle %} - 财务管理 - 账单详情{% endblock %}

{% block extCSS %}
<style type="text/css">
    .tmp{
        display : none;
    }
</style>
{% endblock %}

{% block extJS %}
<script language="JavaScript" type="text/javascript">
//<![CDATA[
    function toApprove(){
       $("#flag").val('{{FIN_APPROVE}}');
       $("#accountID").val($("input[name='account']").radioval());
       $("#appForm").submit();
    }
    
    function toReject(){
        $("#flag").val('{{FIN_REJECT}}');
        $("#appForm").submit();
    }
//]]>
</script>
{% endblock %}


{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="{{url_for('bpRoot.view')}}">基础信息</a></li>
          {% if obj.direction == FIN_IN %}
            <li><a href="{{url_for('bpFin.view',action='index_in')}}">
          {% elif obj.direction == FIN_OUT %}
            <li><a href="{{url_for('bpFin.view',action='index_out')}}">
          {% endif %}
                财务管理</a></li>
          <li class="active">账单详情</li>
        </ol>
    </div>
    <div class="row">
    <ul class="nav nav-tabs">
      <li class="active"><a href="#">账单详情</a></li>
      <li><a href="{{url_for('.view',action='viewLog',id=obj.id)}}">日志记录</a></li>
    </ul>
    </div>
    <div class="row">
        <div class="btn-toolbar pull-right">
            {% if obj.editable() %}
                <div class="btn-group"><a class="btn btn-default" href="{{url_for('.view',action='update',id=obj.id)}}">{{BTN_UPDATE}}</a></div>
            {% endif %}
            {% if obj.approvable() %}
                <div class="btn-group"><a class="btn btn-primary" data-toggle="modal" href="#appModal">{{BTN_ACCEPT}}</a></div>
                <div class="btn-group"><button class="btn btn-primary" onclick="toReject()">{{BTN_REJECT}}</button></div>
            {% endif %}
            {% if obj.deletable() %}
                <div class="btn-group"><a class="btn btn-danger" href="{{url_for('.view',action='delete',id=obj.id)}}">{{BTN_DELETE}}</a></div>
            {% endif %}
        </div>
    </div>
    <div class="row">
        <fieldset>
            <legend>账单详情</legend>
            <div class="col-md-4">
                <h4>系统编号</h4><p>{{obj.no}}</p>
                <h4>账单类型</h4><p>{{obj.direction|ss(c='FIN')}}&nbsp;</p>
                <h4>发票号码</h4><p>{{obj.invoiceNo|f}}&nbsp;</p>
                {% if obj.direction == FIN_IN %}
                    <h4>发票抬头</h4><p>{{obj.issueTo|f}}&nbsp;</p>
                {% elif obj.direction == FIN_OUT %}
                    <h4>开发票方</h4><p>{{obj.issueFrom|f}}&nbsp;</p>
                {% endif %}
                <h4>涉及</h4>
                <p>
                    {{ mymacros.render_goto_popup(obj.refer) }}
                </p>
            </div>
            <div class="col-md-4">
                <h4>开票时间</h4><p>{{obj.createTime|fd}}&nbsp;</p>
                <h4>经办人</h4><p>{{obj.createBy}}&nbsp;</p>
                <h4>备注</h4><p>{{obj.remark|f}}&nbsp;</p>   
            </div>
            <div class="col-md-4">
                <h4>总金额</h4><p>{{obj.amount}}&nbsp;</p>
            </div>
            <div class="col-md-12">
                <h4>附件</h4>
                {{mymacros.render_preview_all_attachment(obj.attachment)}}
            </div>
            <div class="col-md-12">
                <table class="table table-bordered" id="dtls_tb">
                    <thead>
                        <tr>
                            <td class="col-md-2">项目名称</td>
                            <td>项目描述</td>
                            <td class="col-md-2">单价</td>
                            <td class="col-md-1">数量</td>
                            <td class="col-md-2">金额</td>
                            <td class="col-md-2">备注</td>
                        </tr>
                    </thead>
                    <tbody>
                        {% for d in obj.dtls %}
                        <tr>
                            <td>{{d.itemName|f}}</td>
                            <td>{{d.desc|f}}</td>
                            <td>{{d.price}}</td>
                            <td>{{d.qty}}</td>
                            <td>{{d.amount}}</td>
                            <td>{{d.remark|f}}</td>
                        </tr>
                        {% endfor %}
                    </tbody>                
                </table>                
            </div>
        </fieldset>
        {{mymacros.render_system_info(obj)}}
    </div> 
   
</div>


{% if obj.approvable() %}
<form id="appForm" method='POST' action="{{url_for('bpFin.view',action='app')}}" style="display: none;">
    <input type="hidden" name="id" id="id" value="{{obj.id}}"/>
    <input type="hidden" name="accountID" id="accountID" value=""/>
    <input type="hidden" name="flag" id="flag" value=""/>
</form>
{% endif%}

{% if obj.approvable() %}
<!-- modal begin -->
<div id="appModal" class="modal hide fade" tabindex="-1" data-width="560" aria-hidden="true" style="display: none;">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    {% if obj.direction == FIN_IN %}
        <h4>应收账户</h4>
    {% elif obj.direction == FIN_OUT %}
        <h4>应付账户</h4>
    {% endif %}
  </div>
  <div class="modal-body">
    <div class="row">
        {% for a in accounts %}
            <col-md- class="col-md-6">                
            <label class="radio">
              {% if loop.first %}
                <input type="radio" name="account" value="{{a.id}}" checked/>
              {% else %}
                  <input type="radio" name="account" value="{{a.id}}"/>
              {% endif %}
              {{a.no}} - {{a.name}} - {{a.owner}}
            </label>
            </span>
        {% endfor %}
    </div>
  </div>
  <div class="modal-footer">
    <button type="button" data-dismiss="modal" class="btn btn-default">关闭</button>
    <button type="button" class="btn btn-primary" onclick="toApprove()">确定</button>
  </div>
</div>
<!-- modal end -->
{% endif %}


{% endblock %}